package scala.patternMatching

object TypeMatchOB {
   
   def main(args: Array[String]): Unit = {
      val list = List(1, "hai", 'b', 4.5)
      for (element <- list) {
         element match {
            case i: Int    => println(i + " is an integer")
            case s: String => println(s + " is a string")
            case c: Char   => println(c + " is a character")
            case f: Double => println(f + " is a double ")
         }
      }

      //matching on sequense
      val willWork = List(1, 3, 23, 90)
      val willNotWork = List(4, 18, 52)
      val empty = List()

      for (l <- List(willWork, willNotWork, empty)) {
         l match {
            case List(_, 3, _, _) => println(l+ " : List has second element is : 3")
            case List(_*)         => println(l+ " : Another type of list")
         }
      }
   }
}